package com.wxh.jwt.interceptor;

import com.wxh.jwt.common.ResponseInfo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName: GloablExceptionHandler
 * @Description: 全局统一异常处理
 * @Author wxh
 * @Date: 2020/5/28 16:58
 * @Version V1.0.0
 * @Since 1.8
 */
@ControllerAdvice
public class GloablExceptionHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public ResponseInfo handleException(Exception e){
        String msg = e.getMessage();
        if(msg == null || "".equals(msg)){
            msg = "服务器500出错";
        }
        ResponseInfo result = new ResponseInfo();
        result.setMsg(msg);
        return result;
    }
}
